package com.yf.controller.admin.course;

import java.util.List;
import java.util.Map;

import com.yf.entity.course.LessonRecordEntity;
import com.yf.service.course.LessonRecordService;
import com.yf.vo.LessonRecordBackVo;
import com.yf.vo.OrderBackVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import com.yf.response.R;
import com.yf.consts.DaoConst;


/**
 * 上课记录Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Wed Oct 31 09:51:27 CST 2018
 */
@RestController
@RequestMapping("/lessonrecord")
public class LessonRecordController {
    @Autowired
    private LessonRecordService lessonRecordService;

    /**
     * 列表上课记录
     */
    @RequestMapping("/list")
    @RequiresPermissions("lessonrecord:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<LessonRecordEntity> lessonRecordList = lessonRecordService.queryList(params);
        return R.ok(new PageInfo(lessonRecordList));
    }

    /**
     * 查看上课记录
     */
    @SysLog("查看上课记录")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("lessonrecord:info")
    public R info(@PathVariable("id") Long id) {
        LessonRecordEntity lessonRecord = lessonRecordService.get(id);

        return R.ok(lessonRecord);
    }

    /**
     * 保存上课记录
     */
    @SysLog("保存上课记录")
    @RequestMapping("/save")
    @RequiresPermissions("lessonrecord:save")
    public R save(LessonRecordEntity lessonRecord) {
        lessonRecordService.save(lessonRecord);

        return R.ok(lessonRecord);
    }

    /**
     * 修改上课记录
     */
    @SysLog("修改上课记录")
    @RequestMapping("/update")
    @RequiresPermissions("lessonrecord:update")
    public R update(LessonRecordEntity lessonRecord) {
        lessonRecordService.update(lessonRecord);

        return R.ok(lessonRecord);
    }

    /**
     * 删除上课记录
     */
    @SysLog("删除上课记录")
    @RequestMapping("/delete")
    @RequiresPermissions("lessonrecord:delete")
    public R delete(@RequestBody Long[]ids) {
        lessonRecordService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有上课记录
     */
    @SysLog("所有上课记录")
    @RequestMapping("/queryAll")
    public R queryAll(@RequestParam Map<String, Object> params) {

        List<LessonRecordEntity> lessonRecordList = lessonRecordService.queryList(params);

        return R.ok(lessonRecordList);
    }

    /***********自定义开始***********/

    /**
     * back 上课记录
     * @return
     */
    @RequestMapping("/lessonRecordList")
    public R getCampaignVoList(@RequestParam Map<String, Object> params) {
        PageHelper.startPage(DaoConst.getPage(params), DaoConst.getLIMIT(params));
        List<LessonRecordBackVo> list = lessonRecordService.lessonRecordList(params);
        return R.ok(new PageInfo(list));

    }
}
